<?php
namespace products;

use Exception;
use bank\BankUtils;

abstract class Credit extends BankProduct {
	
	private $monthlyPayment;
	private $currentDebt;
	
	public function __construct($accountName, $interestPerYear, $timePeriod, $currentMoneyAmount) {
		
		parent::__construct($accountName, $interestPerYear, $timePeriod, $currentMoneyAmount);
		
		$this->setMonthlyPayment($currentMoneyAmount, $interestPerYear, $timePeriod);
		$this->setCurrentDebt(($timePeriod*$this->monthlyPayment)*-1);
		
	}
	
	public function setMonthlyPayment($currenteMoneyAmount, $interestPerYear, $timePeriod) {
		
		$this->monthlyPayment = BankUtils::calculateCreditMontlyPayment($currenteMoneyAmount, $interestPerYear, $timePeriod);
	}
	
	public function getMonthlyPayment() {
		
		return $this->monthlyPayment;
	}
	
	public function setCurrentDebt($currentDebt) {
		
		$this->currentDebt = $currentDebt;
	}
	
	public function getCurrentDebt() {
		
		return $this->currentDebt;
		
	}
}